package com.hust.bridgecheck.repository;

import com.hust.bridgecheck.entity.Notify;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public interface NotifyRepository extends JpaRepository<Notify,Integer> {
    //获取所有未读信息
    @Query(nativeQuery = true,value = "select * from notify where uid = ?1 and readed = ?2 ")
    public List<Notify> getAllUnreadNotify(Integer uid,Integer readed);

    @Transactional
    @Modifying(clearAutomatically = true)
    @Query(nativeQuery = true, value = "update notify set readed = 1 where id = ?1")
    public int UpdateReaded(Integer NID);
}
